<?php
require_once '../Miffos/Library/Form.php';

echo "<h1>Testing class: Form</h1>\n";
/**
 * Experiment with class Form
 */

/**
 * Create Instance
 */
echo "<h2>Create Html element</h2>\n";
$form = new Form();
#$form->autoRenderError(false);
$form->addText("name","Name:");
$form['name']->getError()->style = array('color'=>"red");
$form['name']->addRule(Form::FILLED,"Name nesmi byt prazdny !");
$form['name']->addRule(~Form::NUMERIC,"Name nesmi byt cislo!");
$form->addPassword("password","Password:");
$form['password']->addRule(Form::FILLED,"Password nesmi byt prazdny !");
$form['password']->getPrototype()->setText('*');
$form->addText('country',"Mesto:")->getPrototype()->style = array('background'=>"yellow");
$form->addFile('file', "Soubor:")->setMaxSize(10000)->setAllowType('image/jpeg');
$form->addTextarea('textarea', "Text:")->setValue('haha');
$form->addSelect('select',"Capital city:",array('praha'=>"Praha",'brno'=>"Brno",'ext'=>array('praha'=>"Praha",'brno'=>"Brno")));
$form->addRadio('sex',"Sex:",array('male'=>"Muz",'zena'=>"Zena"));
$form->addCheckbox('ok','Souhlasite s pravidly ?'/* ,false */);
$form->addCheckbox('no','Nesouhlasite s pravidly ?',true);
$form->addSubmit("Submit data :)");
$form->addReset("Resetuj!");
$form->afterSubmit('funkce');
#var_dump($form);


if($form->isSubmit())
if($form->isValid()){
    print_r($form->getData());
}else{
    $form->addMessage('Moje');
    var_dump( $form->getMessages() );
}

echo $form;

function funkce($data){
    var_dump($data['file']->moveto('Form.Upload.file/'));
}
?>